/**
 * Created by thanatos on 15-6-30.
 */

(function ($, angular) {

    /*主工程*/
    var main_app = angular.module('main_app', ['ui.router'])

    main_app.config(function($stateProvider, $urlRouterProvider){
        $stateProvider
            .state('config', {
                url: '/config',
                views: {
                    'main_view': {templateUrl: 'config/main.html'}
                }
            })
            .state('content', {
                url: '/content',
                views: {
                    'main_view': {templateUrl: 'content/main.html'}
                }
            })
            .state('data', {
                url: '/data',
                views: {
                    'main_view': {templateUrl: 'data/main.html'}
                }
            })
            .state('extend', {
                url: '/extend',
                views: {
                    'main_view': {templateUrl: 'extend/main.html'}
                }
            })
            .state('maintain', {
                url: '/maintain',
                views: {
                    'main_view': {templateUrl: 'maintain/main.html'}
                }
            })
            .state('user', {
                url: '/user',
                views: {
                    'main_view': {templateUrl: 'user/main.html'}
                }
            })
            .state('workspace', {
                url: '/workspace',
                views: {
                    'main_view': {templateUrl: 'workspace/main.html'}
                }
            })
            .state('user.members', {
                url: '/members',
                views: {
                    'user-content-view': {templateUrl: 'user/members.html'}
                }
            })
        $urlRouterProvider.otherwise('/config')
    }).run(function ($rootScope, $location) {
        console.log('path is '+$location.path)
        $rootScope.path = $location.path()
        $rootScope.$on('$routeChangeSuccess', function () {
            $rootScope.path = $location.path()
        })
    })

})(jQuery, angular)